﻿
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:th="http://www.thymeleaf.org">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>添加部门</title>
    <link href="~/css/bootstrap.min.css" rel="stylesheet" type="text/css" />

    <style>
        *, h1, .table, label, td, tr, h2 {
            padding: 0;
            margin: 0
        }

        .top_out {
            padding-bottom: 10px;
        }

        .table tr td:nth-child(2n+1) {
            background-color: #f9f9f9;
            text-align: right;
            font-weight: bold;
            color: #46647e;
            font-size: 14px;
            width: 120px;
            line-height: 40px
        }

        .top {
            border: 1px solid #c1d3de;
            border-top: none
        }

            .top td {
                border: 2px #efefef solid
            }

            .top select, .top input {
                text-align: left;
                border: 1px #ccc solid;
                width: 100%;
                height: 40px;
                border-radius: 4px
            }

            .top td textarea {
                width: 100%;
                height: 150px;
                resize: none;
                border: 1px #ccc solid;
                border-radius: 4px
            }

        .bot_btn {
            width: 150px;
            height: 30px;
            margin: 0 auto 10px auto
        }

            .bot_btn .btn {
                width: 60px;
                height: 30px;
                background-color: #68b86c;
                border: none;
                border-radius: 6px;
                color: #fff;
                margin-right: 15px;
                text-align: center
            }

            .bot_btn .btn1, .bot_btn .btn1 a {
                background-color: #c1d3de;
                border: none;
                border-radius: 6px;
                color: #000;
                margin-right: 0;
                text-decoration: none
            }

                .bot_btn .btn1 a {
                    display: block
                }

        .title {
            background: url(images/righttitlebig.png) repeat-x;
            border: 1px solid #c1d3de;
            overflow: visible;
        }

            .title h2 {
                line-height: 33px;
                margin-left: 7px;
                padding-left: 22px;
                font-weight: bold;
                font-size: 14px;
                font-family: '宋体';
                color: #000000;
                background: url(images/titleico.png) no-repeat left center;
            }

        .i_start {
            width: 8px;
            height: 8px;
            position: relative;
            display: inline-block;
            background-image: url("images/start.png");
            margin-right: 5px;
            top: -2px;
        }
    </style>
    <script type="text/javascript" src="~/js/jquery.js"></script>
    <script>
        function change() {
            var height01 = $(window).height();
            $(".top").css('height', height01 - 35 + "px");
        }
    </script>
</head>

<body style="border-radius: 8px" onload="change()">
    <!--<div class="title"><h2>通知详情</h2></div>-->
    <form id="form_demo">
        <div class="top">
            <div>
                <div class="top_out">

                    <table class="table">
                        <tbody>
                            <tr>
                                <td style="border-top: none">部门名称：<i class="i_start"></i></td>
                                <td colspan="6" style="text-align: left;border-top: none"><input type="text" id="name" name="name" minlength="2" required></td>
                            </tr>
                            <tr>
                                <td style="border-top: none">上级部门ID：</td>
                                <td colspan="6" style="text-align: left;border-top: none">
                                    <input type="text" name="name" id="id" />
                                </td>
                            </tr>
                            <tr>
                                <td style="border-top: none">等级：</td>
                                <td colspan="6" style="text-align: left;border-top: none">
                                    <input type="text" name="name" id="grade" />
                                </td>
                            </tr>
                            <tr>
                                <td style="line-height: 150px">备注：</td>
                                <td colspan="6" style="text-align: left"><textarea id="editor"></textarea></td>
                            </tr>
                        </tbody>
                    </table>
                </div>
            </div>
            <div class="bot_btn">
                <input type="button" class="btn" id="btn" value="保存" />
                <button class="btn btn1"><a href="notice.html" target="right">返回</a></button>
            </div>
        </div>
    </form>
</body>
<script type="text/javascript" src="~/js/jquery.js"></script>
<script src="~/js/layer.js"></script>
<script>
    /*  $.validator.setDefaults({
          submitHandler: function() {
              alert("修改成功");
          }
      });
      $().ready(function() {
          $("#form_demo").validate();
      });*/
     ///部门管理添加方法
    $(function () {
        $("#btn").click(function () {
            var data = {};
            data.DepartName = $("#name").val();
            data.DepartFatherId = $("#id").val();
            data.Grade = $("#grade").val();
            data.Describe = $("#editor").val();
            var name = data.DepartName;
            $.ajax({
                type:"post",
                url:"/Part/QueryPart?name="+ name,
                success: function (result) {
                    if (result.success) {
                         layer.msg('部门名称重复!', { icon: 6, time: 1000 });
                    } else {
                        $.ajax({
                            type: "post",
                            url: "/Part/PartAdd",
                            data: data,
                            success: function (operate) {
                                if (operate.Success) {
                                    layer.msg('添加成功!', { icon: 6, time: 1000 });
                                    window.location.href = "/Home/Part";
                                } else {
                                    layer.msg('添加失败!', { icon: 6, time: 1000 });
                                }
                            }
                        })
                    }
                }
            })

        })
    })
</script>


</html>
